class_name InputManager
extends RefCounted


enum InputAction {
	MOVE_LEFT,
    MOVE_RIGHT,
    MOVE_UP,
    MOVE_DOWN,
    DASH
}


const ACTION_MAP: Dictionary[InputAction, String] = {
    InputAction.MOVE_LEFT: "move_left",
    InputAction.MOVE_RIGHT: "move_right",
    InputAction.MOVE_UP: "move_up",
    InputAction.MOVE_DOWN: "move_down",
    InputAction.DASH: "dash",
}


var enable: bool = true

var movment_direction: Vector2:
    get: return _direction
var _direction: Vector2 = Vector2.ZERO


func is_move_pressed() -> bool:
    return _direction != Vector2.ZERO

func is_dash_pressed() -> bool:
    return Input.is_action_just_pressed(ACTION_MAP[InputAction.DASH])


func process_input():
    if not enable:
        _direction = Vector2.ZERO
        return
    _direction = Input.get_vector(ACTION_MAP[InputAction.MOVE_LEFT],
                                    ACTION_MAP[InputAction.MOVE_RIGHT],
                                    ACTION_MAP[InputAction.MOVE_UP],
                                    ACTION_MAP[InputAction.MOVE_DOWN])
